package com.niiwoo.civet.trade.dto.response.kaola;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * 考拉理财响应DTO
 *
 * @author liming
 * @date 2017-12-29 14:38
 */
@Getter
@Setter
public class KaoLaBaseResponseDTO implements Serializable {
    /**
     * 返回结果
     */
    private byte result;
    /**
     * 结果描述
     */
    private String message;

    public boolean isSuccess(){
        return this.result == KaoLaBaseResponseResultEnum.SUCCESS.getCode();
    }

    public String toString(){
        return JSON.toJSONString(this, SerializerFeature.WriteNullStringAsEmpty);
    }

    @Getter
    @AllArgsConstructor
    public enum KaoLaBaseResponseResultEnum {
        SUCCESS((byte)1,"成功"),
        FAIL((byte)2,"失败");

        private byte code;
        private String description;
    }
}
